"""
@Author  : 康帅
@Time    : 2021/3/18 10:38
@Function: 代理模式：代取快递案例v2.0
"""
from DesignMode.ProxyMode.ExpressDeliveryBase import Subject, ProxySubject


class TonyReception(Subject):
    """ Tony接收 """

    def __init__(self, name, phone_num):
        super().__init__(name)
        self.__phone_num = phone_num

    def get_phone_num(self):
        return self.__phone_num

    def request(self, content=''):
        print("货物主人：%s,手机号：%s" % (self.get_name(), self.get_phone_num()))
        print("接收到一个包裹，包裹内容：%s" % str(content))


class WendyReception(ProxySubject):
    """ Wendy代收 """

    def __init__(self, name, receiver):
        super().__init__(name, receiver)

    def pre_request(self):
        print("我是%s的朋友，我来帮他取快递！" % (self._real_subject.get_name() + ""))

    def after_request(self):
        print("代收人：%s" % self.get_name())


if __name__ == '__main__':
    tony = TonyReception("Tony", "13166668888")
    print("Tony接收：")
    tony.request("雪地靴")
    print()

    print("Wendy代收：")
    wendy = WendyReception("Wendy", tony)
    wendy.request("雪地靴")
